var QQMapWX = require('../../lib/qqmap-wx-jssdk.js');
var utils = require('../../utils/utils.js');
var tempFilePaths = [];
var region = "";
var longitude;
var latitude;
var content="";
var topic;
var openid;
//获取应用实例
var app = getApp()
Page({
  data: {
    

  },

  bindPickerChange: function (e) {
    console.log(this.data.array[e.detail.value]);
  },
  // 获取内容
  getcontent: function (e) {
    content = e.detail.value;
  },
  bindCancel: function () {
    wx.navigateBack({})
  },
  // 上传

  bindSave: function (e) {
    var that=this;
    if(content==""){
      wx.showToast({
        title: '不能为空',
      })
      return;

    } else if (content.length>150){
      wx.showToast({
        title: '最多150个字符',
      })
      return;
    }else{
      wx.request({
        url: app.globalData.url + 'addComment/',
        method: 'POST',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          topic: '',
          content: content,
          openid: openid
        },
        success: (res) => {
          console.log(res);
          wx.showLoading({
            title: '发布成功',
          })
          setTimeout(function () {
            wx.hideLoading()
          }, 1000)
          that.deleteL()
        },
        fail: function (res) {

        },
        complete: function (res) {

        }
      })
    }
   
  },
  // 删除框中的内容
  deleteL:function(){
    this.setData({content:""})
  },
  // 取消
  bindCancel: function () {
    wx.navigateBack();
  },





  onLoad: function (e) {
    var use=wx.getStorageSync('use')
    openid=use.openid;
  }


})



